
package simuri.uridb;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 *
 * @author fomy
 */
public class DbLookUp {
    
    
     public Integer getUriId(String uri){
      int uriid=0;
      Connection con = DbConnection.getConnection();
      try {
          Statement stmt = con.createStatement();  
          String sq ="SELECT UriId FROM uri_aprioriscores WHERE uri_name ='" + uri + "'";
          ResultSet cursor = stmt.executeQuery(sq);
          while (cursor.next()){
          uriid= cursor.getInt("UriId");
          }
           stmt.close();
           con.close();
          }catch (Exception sqlEx){
       System.err.println(sqlEx);
    }
     return uriid;
}

 public String getUriName (int uriid){

     String uriname = null;
     Connection con = DbConnection.getConnection();
     try {
         Statement stmt = con.createStatement();  
         String sq ="SELECT uri_name FROM uri_aprioriscores WHERE UriId='" + uriid + "'";
         ResultSet cursor = stmt.executeQuery(sq);
          while (cursor.next()){    
            uriname= cursor.getString("Uri_name");
          }
           stmt.close();
           con.close();
            }catch (Exception sqlEx){
      System.err.println(sqlEx);
    }
     return uriname;
 }
    
}
